package com.yousu.dashijixm;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

/**
 * @Author: YouSu
 * @Version: 1.0
 * @CreateTime: 2023-11-29  17:22
 */
@SpringBootTest //运行测试前会测试spring容器
public class RedisDemo {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    public void set(){
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        ops.set("name","su");
    }
    @Test
    public void get(){
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        String name = ops.get("name");
        System.out.println(name);
    }
    @Test
    public void delect(){
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        ops.getOperations().delete("name");
    }
}
